@(athugasemdForm: Form[models.data.Athugasemdir], graphData: List[models.domain.Graph],project: models.domain.Project,
athugasemdir: List[models.domain.Comments], spurningar: List[models.domain.SpurningarModel], loggedInName: String, loggedInKt: String,
studentsInGroup: List[models.general.vNemandiAfangarOnn], hopskil: Int, loggedInId: String, skilafrestur_lidinn: Boolean, athugasemdNemenda: String,
vidhengiNemenda : List[models.data.Vidhengitaflanemendur], vidhengiFraKennara : List[models.data.Vidhengitafla], hopurId: Int)
@main(title = "Verkefni") {
    <script src="/public/javascripts/amcharts.js" type="text/javascript"></script>

    <link rel="stylesheet" href="/public/stylesheets/main.css">
    <script type="text/javascript">
            var chart;
            var arr = [];
            @for(graph <- graphData) {
                var obj = new Object();
                obj.x_as = @{graph.getX_as};
                obj.x_as = @{graph.getX_as};
                obj.y_as = @{graph.getY_as};
                if(@{graph.getYou} == true){
                obj.color = "#00CC00";
                }
                else{
                obj.color = "#08c";
                }
                arr.push(obj);
            }

            var chartData = arr;


            AmCharts.ready(function () {
            chart = new AmCharts.AmSerialChart();
            chart.dataProvider = chartData;
            chart.categoryField = "x_as";
            chart.rotate = false;
            chart.depth3D = 20;
            chart.angle = 30;

            // AXES
            // Category
            var categoryAxis = chart.categoryAxis;
            categoryAxis.gridPosition = "start";
            categoryAxis.axisColor = "#DADADA";
            categoryAxis.fillAlpha = 1;
            categoryAxis.gridAlpha = 0;

            // value
            var valueAxis = new AmCharts.ValueAxis();
            valueAxis.axisColor = "#DADADA";
            valueAxis.gridAlpha = 0.1;
            chart.addValueAxis(valueAxis);

            // GRAPH
            var graph = new AmCharts.AmGraph();
            graph.valueField = "y_as";
            graph.type = "column";
            graph.lineAlpha = 0;
            graph.colorField="color";
            graph.fillAlphas = 1;
            chart.addGraph(graph);

            // WRITE
            chart.write("chartdiv");
            $("g").find("tspan").last().hide();
            });
    </script>

    <div class="container conLower">

        <div class="row">
            <div class ="span1">
            </div>
            <div class="span9">
                <h2>@{project.getName}</h2>
                <table class = "table table-striped">
                    <tr class= "table_smallerFont">
                        <th>Nafn</th>
                        <td> @project.getName</td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr class ="table_smallerFont">
                        <th>Lagt fyrir </th>
                        <td>@project.getBeginDate</td>
                        <td>&nbsp;</td>

                    </tr>
                    <tr class="table_smallerFont">
                        <th> Skilafrestur </th>
                        <td> @project.getHandInDate</td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr class ="table_smallerFont">
                        <th> Skilað/Óskilað</th>
                        @if(project.getHandedIn==true){
                            <td>Skilað</td>
                        }
                        @if(project.getHandedIn==false){
                            <td>Óskilað</td>
                        }
                        <td>&nbsp;</td>
                    </tr>
                    <tr class ="table_smallerFont">
                        <th> Vægi </th>
                        <td> @{project.getWeight} %</td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr class ="table_smallerFont">
                        <th> Einkunn </th>
                         @if(project.getGrade == 20.0 || skilafrestur_lidinn ==false){
                        <td> - </td>
                        <td>&nbsp;</td>
                    }else{
                        <td> @project.getGrade </td>
                        <td>&nbsp;</td>
                    }
                    <tr class ="table_smallerFont">
                        <th>Athugasemd frá kennara: </th>
                        @if(project.getAthugasemdFraKennara == null){
                            <td> </td>
                            <td>&nbsp;</td>
                        }
                        @if(project.getAthugasemdFraKennara != null){
                            <td> @{project.getAthugasemdFraKennara}</td>
                            <td>&nbsp;</td>
                        }
                    </tr>
                    @if(vidhengiFraKennara != null){
                        @for((vidhengiKenn,i) <- vidhengiFraKennara.zipWithIndex){
                            <tr>
                                @if(i==0){
                                    <th> Vidhengi</th>
                                }else{
                                    <th>&nbsp;</th>
                                }
                                @helper.form(action = routes.CommonController.download(vidhengiKenn.getSpurning_id),'enctype -> "multipart/form-data", 'class -> "form-horizontal") {
                                    <form method="get" action="@{vidhengiKenn.getNafn}">
                                        <td><button type="submit" title="Ná í viðhengi" class="btn btn-primary btn-small">
                                            <i class="icon-download-alt"></i>
                                        </button>
                                            @{vidhengiKenn.getNafn} </td>
                                    </form>
                                }
                                @if(vidhengiKenn.getContenttype=="application/pdf"){
                                    @helper.form(action= routes.CommonController.openPdfInBrowser(vidhengiKenn.getSpurning_id),'enctype -> "multipart/form-data", 'class -> "form-horizontal"){
                                        <td style="width:115px"><button type="submit" title="Opna skjalið í vafra" class="btn btn-primary btn-small">
                                            <i class="icon-globe"></i> Opna í vafra
                                        </button>
                                        </td>
                                    }
                                }else{
                                    <td> &nbsp;</td>
                                }
                            </tr>
                        }

                    }
                </table>
            </div>
            <div class="span1">
            </div>
        </div>

        <div class = "row">
            <div class="span1">
            </div>
            <div class ="span9">

                @helper.form(action = routes.StudentController.submitAssignment(project.getVerkefniNemenda_id, project.getVerkefni_id),'enctype -> "multipart/form-data", 'class -> "form-horizontal") {
                    @if(!spurningar.isEmpty){
                        <h3>Spurningar</h3>
                        @for((spurn,j) <- spurningar.zipWithIndex){
                            <div class ="well well-small">
                                @if(skilafrestur_lidinn == true){
                                    <h5>Spurning @(j+1) - @{spurn.getVaegi}%</h5>
                                    <p>@{spurn.texti}</p>
                                    @if(spurn.tegund == "texti"){
                                        <input type ="hidden" name ="tegund" value = "@{spurn.getTegund}">
                                        <input type ="hidden" name ="spurning_id" value = "@{spurn.getSpurningar_id}">
                                        <input type = "hidden" name ="fjoldi_svara" value = "@{spurn.getFjoldiSvara}">

                                        @if(spurn.svar != null){
                                            <p><textarea name= "svar" class="input-xxlarge span8" disabled='disabled' title ="Skilafrestur er liðinn">@{spurn.getSvar}</textarea></p>
                                        }else{
                                            <p><textarea name= "svar" class="input-xxlarge span8" placeholder="Svar" disabled='disabled'title ="Skilafrestur er liðinn"></textarea></p>
                                        }
                                    }
                                    @if(spurn.tegund == "eydufylling"){
                                        <input type ="hidden" name ="spurning_id" value = "@{spurn.getSpurningar_id}">
                                        <input type ="hidden" name ="tegund" value = "@{spurn.getTegund}">
                                        <input type ="hidden" name ="fjoldi_svara" value ="@{spurn.getFjoldiSvara}">
                                        @for((eydufylling,i) <- spurn.getEydufyllingar.zipWithIndex){
                                            @{eydufylling}
                                            @if(i != spurn.getEydufyllingar.size-1){
                                                @if(spurn.getEydufyllingarSvor != null){
                                                    <input name ="svar" class ="input-large" value ="@{spurn.getEydufyllingarSvor.get(i)}" disabled='disabled' title ="Skilafrestur er liðinn">
                                                } else{
                                                    <input name= "svar" class="input-large" value="" placeholder="Svar" disabled='disabled' title ="Skilafrestur er liðinn">
                                                }
                                            }
                                        }
                                    }
                                    @if(spurn.tegund == "mynd"){
                                        <input type ="hidden" name = "spurning_id" value ="@{spurn.getSpurningar_id}">
                                        <input type ="hidden" name ="tegund" value = "@{spurn.getTegund}">
                                        <input type ="hidden" name ="fjoldi_svara" value ="@{spurn.getFjoldiSvara}">
                                        <figure> <img src ="data:image/png;base64,@{spurn.getVidhengi}" > </figure>
                                        @if(spurn.getSvar != null){
                                            <textarea name ="svar" class="input-xxlarge span8" disabled='disabled' title ="Skilafrestur er liðinn">@{spurn.getSvar}</textarea>
                                        }else{
                                            <textarea name = "svar" class="input-xxlarge span8" placeholder ="Svar" disabled='disabled' title ="Skilafrestur er liðinn"> </textarea>
                                        }
                                    }

                                    @if(spurn.tegund == "krossar"){
                                        <input type="hidden" name="spurning_id" value ="@{spurn.getSpurningar_id}">
                                        <input type="hidden" name="tegund" value="@{spurn.getTegund}">
                                        <input type="hidden" name="fjoldi_svara" value="@{spurn.getFjoldiSvara}">
                                        @for((krossasvor,i) <- spurn.getKrossaSvor.zipWithIndex){
                                            @if(spurn.getKrossaSvorID.get(i) ==spurn.getKrossaRettSvar && spurn.getValidSvar == spurn.getKrossaSvorID.get(i)){
                                                <p style="font-weight: bold;"><input type="radio" name="krossarSvar@{spurn.getSpurningar_id}" value="@{spurn.getKrossaSvorID.get(i)}" checked disabled='disabled' title ="Skilafrestur er liðinn" >
                                                     @{krossasvor}
                                                </p>
                                            }
                                            @if(spurn.getKrossaSvorID.get(i) !=spurn.getKrossaRettSvar && spurn.getValidSvar == spurn.getKrossaSvorID.get(i) ){
                                                <p><input type="radio" name="krossarSvar@{spurn.getSpurningar_id}" value="@{spurn.getKrossaSvorID.get(i)}" checked disabled='disabled' title ="Skilafrestur er liðinn">
                                                    @{krossasvor}
                                                </p>
                                            }
                                            @if(spurn.getKrossaSvorID.get(i) ==spurn.getKrossaRettSvar && spurn.getValidSvar != spurn.getKrossaSvorID.get(i)) {
                                                <p style="font-weight: bold;"><input type="radio" name="krossarSvar@{spurn.getSpurningar_id}" value="@{spurn.getKrossaSvorID.get(i)}" disabled='disabled' title ="Skilafrestur er liðinn">
                                                    @{krossasvor}
                                                </p>
                                            }
                                            @if(spurn.getKrossaSvorID.get(i) !=spurn.getKrossaRettSvar && spurn.getValidSvar != spurn.getKrossaSvorID.get(i)){
                                                <p><input type="radio" name="krossarSvar@{spurn.getSpurningar_id}" value="@{spurn.getKrossaSvorID.get(i)}" disabled='disabled' title ="Skilafrestur er liðinn">
                                                    @{krossasvor}
                                                </p>
                                            }
                                        }

                                    }
                                    @if(spurn.tegund == "fjolval"){
                                        <input type="hidden" name="spurning_id" value ="@{spurn.getSpurningar_id}">
                                        <input type="hidden" name="tegund" value="@{spurn.getTegund}">
                                        <input type="hidden" name="fjoldi_svara" value="@{spurn.getFjoldiSvara}">
                                        @for((krossasvor,i) <- spurn.getKrossaSvor.zipWithIndex){
                                            @if(spurn.getValinSvor != null){
                                                @if(spurn.getFjolvalRettSvor.get(i) ==1 && spurn.getValinSvor.get(i) == 1){
                                                    <p style="font-weight: bold;"><input type="checkbox" name="fjolvalSvar" value="@{spurn.getKrossaSvorID.get(i)}" checked disabled='disabled' title ="Skilafrestur er liðinn">
                                                        @{krossasvor}
                                                    </p>
                                                }
                                                @if(spurn.getFjolvalRettSvor.get(i) ==1 && spurn.getValinSvor.get(i) == 0){
                                                    <p style="font-weight: bold;"><input type="checkbox" name="fjolvalSvar" value="@{spurn.getKrossaSvorID.get(i)}" disabled='disabled' title ="Skilafrestur er liðinn">
                                                        @{krossasvor}
                                                    </p>
                                                }
                                                @if(spurn.getFjolvalRettSvor.get(i) ==0 && spurn.getValinSvor.get(i) == 1){
                                                    <p><input type="checkbox" name="fjolvalSvar" value="@{spurn.getKrossaSvorID.get(i)}" checked disabled='disabled' title ="Skilafrestur er liðinn">
                                                        @{krossasvor}
                                                    </p>
                                                }
                                                @if(spurn.getFjolvalRettSvor.get(i) ==0 && spurn.getValinSvor.get(i) == 0){
                                                    <p><input type="checkbox" name="fjolvalSvar" value="@{spurn.getKrossaSvorID.get(i)}"  disabled='disabled' title ="Skilafrestur er liðinn">
                                                        @{krossasvor}
                                                    </p>
                                                }

                                            }else{
                                                @if(spurn.getFjolvalRettSvor.get(i) == 1){
                                                    <p style="font-weight: bold;"><input type="checkbox" name="fjolvalSvar" value="@{spurn.getKrossaSvorID.get(i)}" disabled='disabled' title ="Skilafrestur er liðinn">
                                                        @{krossasvor}
                                                    </p>
                                                }else{
                                                    <p><input type="checkbox" name="fjolvalSvar" value="@{spurn.getKrossaSvorID.get(i)}"  disabled='disabled' title ="Skilafrestur er liðinn">
                                                        @{krossasvor}
                                                    </p>
                                                }

                                            }
                                        }


                                    }

                                }else{
                                    @if(spurn.getTegund == "texti"){
                                        <h5>Spurning @(j+1) - @{spurn.getVaegi}%</h5>
                                        <p> @{spurn.texti} </p>
                                        <input type ="hidden" name ="tegund" value = "@{spurn.getTegund}">
                                        <input type ="hidden" name ="spurning_id" value = "@{spurn.getSpurningar_id}">
                                        <input type = "hidden" name ="fjoldi_svara" value = "@{spurn.getFjoldiSvara}">
                                        @if(spurn.svar != null){
                                            <p><textarea name= "svar" maxlength="4000" class="input-xxlarge"> @{spurn.getSvar}</textarea></p>
                                        }else{
                                            <p><textarea name= "svar" maxlength="4000" class="input-xxlarge" placeholder="Svar"></textarea></p>
                                        }
                                    }
                                    @if(spurn.getTegund == "eydufylling"){
                                        <h5>Spurning @(j+1) - @{spurn.getVaegi}%</h5>
                                        @if(spurn.getTexti != null){
                                            <p> @{spurn.getTexti} </p>
                                        }
                                        <input type ="hidden" name ="spurning_id" value = "@{spurn.getSpurningar_id}">
                                        <input type ="hidden" name ="tegund" value = "@{spurn.getTegund}">
                                        <input type ="hidden" name ="fjoldi_svara" value ="@{spurn.getFjoldiSvara}">
                                        @for((eydufylling,i) <- spurn.eydufyllingar.zipWithIndex){
                                            @{eydufylling}
                                            @if(i != spurn.getEydufyllingar.size-1){
                                                @if(spurn.getEydufyllingarSvor != null){
                                                    <input name ="svar" class ="input-large" value = "@{spurn.getEydufyllingarSvor.get(i)}">
                                                } else{
                                                    <input name= "svar" class="input-large" placeholder="Svar">
                                                }
                                            }
                                        }
                                    }
                                    @if(spurn.getTegund == "mynd"){
                                        <h5>Spurning @(j+1) - @{spurn.getVaegi}%</h5>
                                        <p> @{spurn.texti}</p>
                                        <input type ="hidden" name = "spurning_id" value ="@{spurn.getSpurningar_id}">
                                        <input type ="hidden" name ="tegund" value = "@{spurn.getTegund}">
                                        <input type ="hidden" name ="fjoldi_svara" value ="@{spurn.getFjoldiSvara}">
                                        <figure> <img src ="data:image/png;base64,@{spurn.getVidhengi}" > </figure>
                                        @if(spurn.getSvar != null){
                                            <textarea name ="svar" maxlength="4000"class="input-xxlarge span8" >@{spurn.getSvar}</textarea>
                                        }else{
                                            <textarea name = "svar" maxlength="4000" class="input-xxlarge span8" placeholder ="Svar"> </textarea>
                                        }
                                    }
                                    @if(spurn.getTegund == "krossar"){
                                        <h5>Spurning @(j+1) - @{spurn.getVaegi}%</h5>
                                        <p>@{spurn.texti}</p>
                                        <input type="hidden" name="spurning_id" value ="@{spurn.getSpurningar_id}">
                                        <input type="hidden" name="tegund" value="@{spurn.getTegund}">
                                        <input type="hidden" name="fjoldi_svara" value="@{spurn.getFjoldiSvara}">
                                        @for((krossasvor,i) <- spurn.getKrossaSvor.zipWithIndex){
                                            @if(spurn.getValidSvar == spurn.getKrossaSvorID.get(i)){
                                                <p><input type="radio" name="krossarSvar@{spurn.getSpurningar_id}" value="@{spurn.getKrossaSvorID.get(i)}" checked>
                                                    @{krossasvor}
                                                </p>
                                            }else{
                                                <p><input type="radio" name="krossarSvar@{spurn.getSpurningar_id}" value="@{spurn.getKrossaSvorID.get(i)}">
                                            @{krossasvor}
                                                </p>
                                            }
                                        }

                                    }
                                    @if(spurn.tegund == "fjolval"){
                                        <h5>Spurning @(j+1) - @{spurn.getVaegi}%</h5>
                                        <p>@{spurn.texti}</p>
                                        <input type="hidden" name="spurning_id" value ="@{spurn.getSpurningar_id}">
                                        <input type="hidden" name="tegund" value="@{spurn.getTegund}">
                                        <input type="hidden" name="fjoldi_svara" value="@{spurn.getFjoldiSvara}">
                                        @for((krossasvor,i) <- spurn.getKrossaSvor.zipWithIndex){
                                            @if(spurn.getValinSvor != null){
                                                @if(spurn.getValinSvor.get(i) == 1){
                                                    <p><input type="checkbox" name="fjolvalSvar" value="@{spurn.getKrossaSvorID.get(i)}" checked>
                                                        @{krossasvor}
                                                    </p>
                                                }else{
                                                    <p><input type="checkbox" name="fjolvalSvar" value="@{spurn.getKrossaSvorID.get(i)}">
                                                @{krossasvor}
                                                    </p>
                                                }
                                            }else{
                                                <p><input type="checkbox" name="fjolvalSvar" value="@{spurn.getKrossaSvorID.get(i)}">
                                               @{krossasvor}
                                                </p>
                                            }
                                        }
                                    }
                                }
                            </div>
                        }
                    }
                    @if(project.getType == "verkefni"){
                        <h4>Skila viðhengi</h4>
                        <input type="file" name="vidhengi">
                    }


                    <br>
                    <h4>Velja meðlimi í verkefnishóp</h4>
                    <input type="hidden" name="notandiId" value="@loggedInId" style="width: 260px; font-size: 0.7em">
                    <p>@loggedInName - @loggedInKt</p>
                    <br/>
                    @if(hopskil > 1){
                        @for(a <- 2 to hopskil){
                            <select name="notandiId" style="width: 260px; font-size: 0.7em">
                            <option value="null"> - Veldu hópmeðlim - </option>
                                @for(student <- studentsInGroup){
                                    <option  value="@student.notandi_id">
                                        @student.nafn - @student.kennitala
                                    </option>
                                }
                            </select>            <br/>
                        }
                    }
                    <br>
                    @if(athugasemdNemenda != null && skilafrestur_lidinn == true){

                        <h4>Athugasemd til kennara</h4>
                        <p><textarea disabled maxlength="4000" name="athugasemd" class ="input-xxlarge span9">@{athugasemdNemenda} </textarea> </p>
                    }
                    @if(skilafrestur_lidinn == false){
                        <h4>Athugasemd til kennara</h4>
                        <p><textarea maxlength="4000" name="athugasemd" class ="input-xxlarge span9">@{athugasemdNemenda}</textarea> </p>
                    }
                    @if(skilafrestur_lidinn == true && project.getHandedIn == false){

                        <h4>Athugasemd til kennara</h4>
                        <p><textarea disabled maxlength="4000" name="athugasemd" class="input-xxlarge span9">@{athugasemdNemenda} </textarea> </p>
                    }



                    @if(skilafrestur_lidinn == false){
                        <div class="control-group">
                            <div class="form-actions pull-right">

                                <button type="submit" class="btn btn-primary" value="submit">Skila verkefni</button>

                                <a href="@routes.StudentController.studentDashboard()"><input type="button" class="btn" title="Fara til baka á forsíðu" value="Hætta við" /></a>

                            </div>



                        </div>
                    }
                }     <!-- helper-->

                @for((vidhengi,i) <- vidhengiNemenda.zipWithIndex){
                    @if(i == 0){
                        <h4>Viðhengi</h4>
                    }
                    <div> @helper.form(action = routes.CommonController.deleteVidhengiNemendur(vidhengi.getVidhengi_id,project.getVerkefni_id),'enctype -> "multipart/form-data", 'class -> "form-horizontal"){
                        <button type="submit" class="btn btn-primary btn-mini">
                            <i class="icon-trash"></i>
                        </button>
                        @{vidhengi.getNafn}
                    }
                    </div>
                }

            </div>

            <div class ="span1">
            </div>

        </div>
        @if(project.getGradePublished == true ){
            <div class="row">
                <div class="span6" style="padding-left: 80px;">
                    <div id="chartdiv" class="graph" style="width: 160%; height: 300px; vertical-align: middle;"></div>
                </div>
            </div>
        }


        @if(project.getType != "prof"){
            <div class="row">
                <div class="span1">
                </div>
                <div class="span9" >

                    <h4>Umræður varðandi verkefnið: @project.getName</h4>

                    @for(athugasemd <- athugasemdir){
                        <div class="well">
                        <p class="underScore11pt">@athugasemd.getName<span style="float: right">@athugasemd.stofnad_stengur</span></p>
                        <p class="reg11pt">@athugasemd.getTexti
                            <span style="float: right">
                                @if(athugasemd.getNotandi_id==loggedInId){
                                    <a class="btn" href="@routes.CommonController.studentDeletesAthugasemd(athugasemd.athugasemd_id,project.getVerkefni_id) "title="Eyða athugasemd"><i class="icon-trash"></i></a>
                                }
                            </span>
                        </p>
                        </div>

                    }

                    @helper.form(action=routes.CommonController.studentAddsComment(project.getVerkefni_id)) {
                    <p>Bæta við í umræðurnar</p>
                        <input type="hidden" name="hopur_id" value="@hopurId"/>

                        <textarea maxlength="500" class="span9" name="texti"></textarea>
                        <button type="submit" class="btn btn-primary pull-right" value="submit">Staðfesta</button>
                    }

                </div>
                <div class ="span1">
                </div>
                <hr>

            </div>

        }

    </div>
}